package com.rss.controller;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;

import com.rss.controller.XmlParser.Entry;

public class ListAdapter {
	private XmlParser xp;
	private List<String> titles;
	private List<Entry> entries;
	private Activity activity;
	
	
	public ListAdapter(Activity activity, List<Entry> entries) {
		this.xp = new XmlParser();
		this.titles = new ArrayList<String>();
		this.entries = new ArrayList<Entry>();
		this.activity = activity;
	}
	
	public void readXML(String path) {
		try {
			FileInputStream fIn = activity.openFileInput(path);
			entries = xp.parse(fIn);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
	public List<String> getTitles() {
		for (int i = 0; i < entries.size(); i++) {
			titles.add(entries.get(i).title);
		}
		return titles;
	}

	public List<Entry> getEntries() {
		return entries;
	}
	
}
